package com.sofly.controller.group3;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.view.document.AbstractPdfView;

import com.sofly.entity.Bom;
import com.sofly.entity.DataGrid;
import com.sofly.entity.Parts;
import com.sofly.service.group1.IBomService;
import com.sofly.service.group3.IPartsService;
import com.sofly.service.impl.group1.BomService;
/**
 * 订单控制类
* <p>Title:PurchaseListController </p>
* <p>Description: </p>
* <p>Company: </p> 
* @author ChengShiMin
* @date 下午5:52:11
 */
@Controller
public class PartsController {

	@Autowired
	 private DataGrid dataGrid;
	@Autowired
	private IPartsService partsService;
	@Autowired
	private AbstractPdfView abstractPdfView;
	@Autowired
	private IBomService bomService;
	
	@RequestMapping(value="/href/partslist")
	@ResponseBody
	public DataGrid getPartsList(String page,String rows) throws UnsupportedEncodingException{		
		int page1 = Integer.parseInt(page);
		int rows1 = Integer.parseInt(rows);
		List<Parts> list = new ArrayList<>();
		int total = 0;
		 
	     list = partsService.getPageParts((page1-1)*rows1,rows1);
	     total = partsService.getCount();
	     dataGrid.setRows(list);
	     dataGrid.setTotal(total);
	     return dataGrid;
	}
	
	
	@RequestMapping(value="/href/boms")
	@ResponseBody
	public DataGrid goWeb(String text,String parent){
		List<Parts> showP = partsService.findPartsParent(text);
		dataGrid.setTotal(30);
		dataGrid.setRows(showP);
		return dataGrid;
	}
	
	@RequestMapping("/href/Jbom")
	@ResponseBody
	public DataGrid a(Model model,String text){
		List<Bom> bm = bomService.findBomStocknumber(text);
		dataGrid.setTotal(30);
		dataGrid.setRows(bm);
		return dataGrid;
	}

	 
}
